<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'demo-json.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    This is json demo page. <br>
    
    
    <script type="text/javascript">
    
    // json 标准格式{建：值,建1：值1}，javascript作为对象使用
	//var _json = {key:value,key1:value1};
	//var _json = {key:value,key1:value1};
	
	// josn 对象，只包含属性
	var user0 = {name:'张三',age:17};
	alert(user0.name);
	alert(user0.age);
	
	// josn对象，包含属性、方法
	//方法
	var user1 ={
		name : "李四",
		age :30,
				
		work : function (){
			//json对象中，属性调用，需要使用：this.属性名
			alert("这是一个人类的行为，此人为: "+this.name+".age "+this.age);
		}
	}
	
	//
	alert(user1.name);
	alert(user1.age);
	// json对象，方法调用
	user1.work();
    
    </script>
  </body>
</html>
